package com.navinfo.opentsp.qingqi.trackoptimize.util;

import java.util.Calendar;
import java.util.Date;

/**
 * @author wangshuai
 * @date 2019/4/9 16:57
 */
public class CheckUtil {
    /**
     * 验证开始日期是否小于结束日期
     *
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @return boolean true：开始日期大于结束日期
     */
    public static boolean dateCheckCompare(String startDate, String endDate) {
        Date dStartDate = DateUtil.parseDate(startDate, DateUtil.time_pattern);
        Date dEndDate = DateUtil.parseDate(endDate, DateUtil.time_pattern);
        // 开始日期大于结束日期
        return dStartDate.getTime() > dEndDate.getTime();
    }

    /**
     * 比较两个时间跨度大于3个月返回true
     * @param startDate
     * @param endDate
     * @return
     */
    public static boolean dateCheckRange(String startDate, String endDate) {
        Date dStartDate = DateUtil.parseDate(startDate, DateUtil.time_pattern);
        Date dEndDate = DateUtil.parseDate(endDate, DateUtil.time_pattern);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dStartDate);
        calendar.add(Calendar.MONTH, 3);
        return calendar.getTime().getTime() <= dEndDate.getTime();
    }
}
